/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package br.gov.ana.entities;

import java.io.Serializable;
import java.math.BigDecimal;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author lucas.nunes
 */
@Entity
@Table(name = "QLTTB_UNIDADE_MEDIDA")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "UnidadeMedida.findAll", query = "SELECT u FROM UnidadeMedida u"),
    @NamedQuery(name = "UnidadeMedida.findByUnmId", query = "SELECT u FROM UnidadeMedida u WHERE u.unmId = :unmId"),
    @NamedQuery(name = "UnidadeMedida.findByUnmNm", query = "SELECT u FROM UnidadeMedida u WHERE u.unmNm = :unmNm"),
    @NamedQuery(name = "UnidadeMedida.findByUnmTxAbreviacao", query = "SELECT u FROM UnidadeMedida u WHERE u.unmTxAbreviacao = :unmTxAbreviacao"),
    @NamedQuery(name = "UnidadeMedida.findByUnmDs", query = "SELECT u FROM UnidadeMedida u WHERE u.unmDs = :unmDs")})
public class UnidadeMedida implements Serializable {
    private static final long serialVersionUID = 1L;
    // @Max(value=?)  @Min(value=?)//if you know range of your decimal fields consider using these annotations to enforce field validation
    @Id
    @Basic(optional = false)
    @NotNull
    @Column(name = "UNM_ID")
    private BigDecimal unmId;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 104)
    @Column(name = "UNM_NM")
    private String unmNm;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 14)
    @Column(name = "UNM_TX_ABREVIACAO")
    private String unmTxAbreviacao;
    @Size(max = 4000)
    @Column(name = "UNM_DS")
    private String unmDs;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "cvhUnmId")
    private List<CaracterizacaoVhm> caracterizacaoVhmList;

    public UnidadeMedida() {
    }

    public UnidadeMedida(BigDecimal unmId) {
        this.unmId = unmId;
    }

    public UnidadeMedida(BigDecimal unmId, String unmNm, String unmTxAbreviacao) {
        this.unmId = unmId;
        this.unmNm = unmNm;
        this.unmTxAbreviacao = unmTxAbreviacao;
    }

    public BigDecimal getUnmId() {
        return unmId;
    }

    public void setUnmId(BigDecimal unmId) {
        this.unmId = unmId;
    }

    public String getUnmNm() {
        return unmNm;
    }

    public void setUnmNm(String unmNm) {
        this.unmNm = unmNm;
    }

    public String getUnmTxAbreviacao() {
        return unmTxAbreviacao;
    }

    public void setUnmTxAbreviacao(String unmTxAbreviacao) {
        this.unmTxAbreviacao = unmTxAbreviacao;
    }

    public String getUnmDs() {
        return unmDs;
    }

    public void setUnmDs(String unmDs) {
        this.unmDs = unmDs;
    }

    @XmlTransient
    public List<CaracterizacaoVhm> getCaracterizacaoVhmList() {
        return caracterizacaoVhmList;
    }

    public void setCaracterizacaoVhmList(List<CaracterizacaoVhm> caracterizacaoVhmList) {
        this.caracterizacaoVhmList = caracterizacaoVhmList;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (unmId != null ? unmId.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof UnidadeMedida)) {
            return false;
        }
        UnidadeMedida other = (UnidadeMedida) object;
        if ((this.unmId == null && other.unmId != null) || (this.unmId != null && !this.unmId.equals(other.unmId))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "br.gov.ana.service.UnidadeMedida[ unmId=" + unmId + " ]";
    }
    
}
